home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume8 / ansitape / part02 < prev    next >
Encoding:
Internet Message Format  |  1987-03-02  |  32.9 KB

  1. Subject:  v08i100:  ANSI tape program, Part02/02
  2. Newsgroups: mod.sources
  3. Approved: mirror!rs
  4.  
  5. Submitted by: David S. Hayes <sundc!hqda-ai!merlin>
  6. Mod.sources: Volume 8, Issue 100
  7. Archive-name: ansitape/Part02
  8.  
  9.      This is the second part of Ansitape.  It contains the makefile,
  10. the manual pages, and miscellaneous small files.  The program itself is
  11. contained in the first message.
  12.  
  13. [  I left this in its original wrapper because it wouldn't fit in
  14.    one piece, so I didn't tamper... --r$  ]
  15.  
  16. #!/bin/sh
  17. # This is a shell archive.  Remove anything before this line, then
  18. # unpack it by saving it in a file and typing "sh file".  (Files
  19. # unpacked will be owned by you and have default permissions.)
  20. #
  21. # This archive contains:
  22. # Makefile ansitape.h tables.c ansitape.1 ansitape.5.tbl
  23. echo x - Makefile
  24. cat > "Makefile" << '//E*O*F Makefile//'
  25. # Makefile for ANSITAPE
  26. #
  27. # This program creates, reads, writes, and takes directory listings of
  28. # ANSI-formatted tapes. 
  29. #
  30. # This program was developed at 
  31. #
  32. # HQDA Army Artificial Intelligence Center
  33. # Pentagon Attn: DACS-DMA
  34. # Washington, DC  20310-0200 
  35. #
  36. # Phone: (202) 694-6900
  37. # E-mail:
  38. #    Arpa:        merlin%hqda-ai.uucp@smoke.brl.arpa
  39. #        alternate    dshayes@smoke.brl.arpa
  40. #    UUCP:        ...!seismo!sundc!hqda-ai!merlin
  41. #
  42. # Support?  You want support?  What do I look like, a software house?
  43. # Mail me your gripes, comments, and bugs, and I'll try to keep
  44. # up with them.
  45. #
  46. # THIS PROGRAM IS IN THE PUBLIC DOMAIN.
  47.  
  48.  
  49.  
  50. # Define AT MOST ONE of the following
  51. # Define this if you want debugging.
  52. #CCOPT    = -g
  53. # Define this if you want compiler optimizations.
  54. CCOPT    = -O
  55.  
  56.  
  57. # Define this if you want to handle IBM EBCDIC tapes.
  58. IBM    = -DEBCDIC
  59.  
  60.  
  61. # Define this to be the maximum size of a file you are willing to
  62. # read to determine the record length.  Files smaller than this
  63. # are read twice:  once to find the max record length, and the second
  64. # time when writing the tape.  Files larger than this just assume
  65. # that the recordlength == blocklength.  Probably not a great
  66. # assumption, but we have to assume something.
  67. #
  68. # If this is not defined, the ansitape.c uses 100K by default.
  69. #READMAX    = 100000
  70.  
  71.  
  72. # This is the directory where ansitape will go.
  73. BIN    = /usr/local/bin
  74.  
  75.  
  76. # This is the directory where you put your
  77. # unformatted manual pages for commands.
  78. CMDMAN    = /usr/man/man1
  79.  
  80. # This is the directory where you put your
  81. # unformatted manual pages for file formats.
  82. FILEMAN    = /usr/man/man5
  83.  
  84. # This is the directory where you put your
  85. # FORMATTED manual pages for file formats.
  86. # Define this to be /tmp if you don't keep
  87. # formatted copies of the file format manual pages.
  88. # Cron should clean it out eventually.
  89. FILECAT    = /usr/man/cat5
  90.  
  91.  
  92. all: ansitape man
  93.  
  94. ansitape: ansitape.c ansitape.h tables.o
  95.     cc ${CCOPT} -o ansitape ${IBM} ${READMAX} ansitape.c tables.o
  96.     mv ansitape ${BIN}
  97.  
  98. tables.o: tables.c
  99.  
  100. man: man1 man5
  101.  
  102. man1: ansitape.1
  103.     cp ansitape.1 ${CMDMAN}
  104.  
  105. man5: ansitape.5.tbl
  106.     tbl ansitape.5.tbl > ${FILEMAN}/ansitape.5
  107.     tbl ansitape.5.tbl | nroff -man | colcrt > ${FILECAT}/ansitape.5
  108. //E*O*F Makefile//
  109.  
  110. echo x - ansitape.h
  111. cat > "ansitape.h" << '//E*O*F ansitape.h//'
  112.  
  113. /*
  114.  * This file contains the definitions of the tape control records. This
  115.  * is to be used when developing a program to work with ANSI standard
  116.  * labelled tapes. 
  117.  */
  118.  
  119. /*
  120.  * Actually, these should be upper case.  The ansitape program doesn't
  121.  * convert things to upper case until the headers are made -- the tape
  122.  * control block has everything in lower case.  For the sake of easy
  123.  * comparisons, we define them here as lower case. 
  124.  */
  125.  
  126. #define NOPROTECT ' '        /* space if no protection */
  127. #define REC_FIXED 'f'        /* Records are all fixed length */
  128. #define REC_VARIABLE 'd'    /* Records are preceeded by a 4-digit
  129.                  * zero-filled count of their length,
  130.                  * including the 4 digits themselves */
  131. #define IBM_VARIABLE 'v'    /* IBM's version of ANSI D format */
  132. #define CC_FORTRAN 'a'        /* First char of rec is f-77 carriage
  133.                  * control */
  134. #define CC_EMBEDDED 'm'        /* Carriage control is part of the data
  135.                  * contained in each record */
  136. #define CC_IMPLIED ' '        /* Each record goes on a separate line
  137.                  * when printed */
  138.  
  139. /*
  140.  * VOLUME 1 Describes the owner of and access to the volume. 
  141.  */
  142.  
  143. struct ansi_vol1 {
  144.     char            header[4];    /* VOL1 */
  145.     char            label[6];    /* volume name, A-Z0-9 */
  146.     char            access;    /* access code */
  147.     char            __ignored1[20];    /* reserved, space fill */
  148.     char            __ignored2[6];    /* reserved, space fill */
  149.     char            owner[14];    /* user name */
  150.     char            __ignored3[28];    /* reserved, space fill */
  151.     char            ansi_level;    /* ansi standard level, always 3 */
  152. };
  153.  
  154. /*
  155.  * VOLUME 2 optional, ignored by this software. 
  156.  */
  157.  
  158. /*
  159.  * HEADER 1 Begins basic description of a tape file. 
  160.  */
  161.  
  162. struct ansi_hdr1 {
  163.     char            header[4];    /* HDR1 */
  164.     char            name[17];    /* rightmost 17 characters of filename */
  165.     char            fileset[6];    /* should be same as volume id of 1st
  166.                  * tape */
  167.     char            volume_num[4];    /* number of volume in set */
  168.     char            file_num[4];/* number of file on tape */
  169.     char            gen[4];    /* generation number */
  170.     char            genver[2];    /* generation version number */
  171.     char            created[6];    /* date of creation, "bYYDDD" */
  172.     char            expires[6];    /* expiration date "bYYDDD" */
  173.     char            access;    /* protection, space = unprotected */
  174.     char            blockcount[6];    /* zero in header */
  175.     char            tapesys[13];/* name of software creating tape */
  176.     char            __ignored[7];    /* reserved, space fill */
  177. };
  178.  
  179. /*
  180.  * HEADER 2 Record format, record size, block size. 
  181.  */
  182.  
  183. struct ansi_hdr2 {
  184.     char            header[4];    /* HDR2 */
  185.     char            recfmt;    /* record format */
  186.     char            blocklen[5];/* file tape block length */
  187.     char            reclen[5];    /* file logical record length */
  188.     char            density;    /* density/recording mode. Should be 2
  189.                  * for 800 bpi, 3 for 1600 bpi. */
  190.     char            vol_switch;    /* 0, or 1 if this file was continued */
  191.     char            job[17];    /* job name (8), /, job step (8) of
  192.                  * creator */
  193.     char            recording[2];    /* parity/conversion, space
  194.                      * fill */
  195.     char            carriage_control;
  196.     char            alignment;    /* reserved, space fill */
  197.     char            blocked_records;    /* 'B' if records are blocked */
  198.     char            __ignored2[11];
  199.     char            block_offset[2];    /* ingore 1st n char of each
  200.                      * block */
  201.     char            __ignored3[28];
  202. };
  203.  
  204. /*
  205.  * HEADER 3 This contains a bunch of rms-dependent data.  We will
  206.  * ignore it for now, and hope that it doesnt screw up VMS too badly. 
  207.  */
  208.  
  209. struct ansi_hdr3 {
  210.     char            header[4];    /* HDR3 */
  211.     char            os_reserved[76];    /* reserved to OS, space fill */
  212. };
  213.  
  214. /*
  215.  * HEADER 4 This is the rest of the filename if its longer than 17
  216.  * characters.  We should have no trouble fitting UNIX filenames into
  217.  * this. 
  218.  */
  219.  
  220. struct ansi_hdr4 {
  221.     char            header[4];    /* HDR4 */
  222.     char            name2[63];    /* leftmost char, if name is more than
  223.                  * 17 characters long. */
  224.     char            unknown[2];    /* fill with 00 */
  225.     char            __ignored[11];
  226. };
  227.  
  228.  
  229. /*
  230.  * FORMAT NOTES 
  231.  *
  232.  * 1.  The tape always starts with a VOL1 record.  Other volume records
  233.  * are optional.  We ignore them, and do not generate them on output. 
  234.  *
  235.  * 2.  Each file starts with a set of HDRn records.  The headers are
  236.  * followed by a tape mark. 
  237.  *
  238.  * 3.  The data is written to the tape in fixed-length blocks.  Valid ANSI
  239.  * block lengths are 18 to 2048 bytes, although VMS will support longer
  240.  * blocks. The block does not have to be full.  If the block is not
  241.  * completely filled, the remainder of the block is padded with
  242.  * circumflex (^) characters.  The file is followed by a tape mark. 
  243.  *
  244.  * 4.  Trailing records are written.  Either EOF or EOV records may be
  245.  * used. The record formats are the same as the HDR records, expect: 
  246.  *
  247.  * a. the "HDR" is replaced by "EOF" or "EOV". 
  248.  *
  249.  * b. the blockcount field in EOF1/EOV1 contains the actual number of
  250.  * physical tape blocks written in the preceding file section.  In the
  251.  * HDR1 record, the blockcount is 000000. 
  252.  *
  253.  * 5.  A tape file may extend across a volume boundary.  If it does, EOV
  254.  * labels are used, indicating that another tape must be read.  If the
  255.  * file ends here, an EOF label is used. 
  256.  *
  257.  * 6.  After the EOF records, a tape mark is written.  This separates the
  258.  * trailers from the headers for the next file.  At the end of the
  259.  * tape, two tape marks are written. 
  260.  */
  261. //E*O*F ansitape.h//
  262.  
  263. echo x - tables.c
  264. cat > "tables.c" << '//E*O*F tables.c//'
  265. /* Mapping of EBCDIC codes to ASCII equivalents. */
  266. static char     to_ascii_table[256] = {
  267.                        '\000', '\001', '\002', '\003',
  268.                        '\234', '\011', '\206', '\177',
  269.                        '\227', '\215', '\216', '\013',
  270.                        '\014', '\015', '\016', '\017',
  271.                        '\020', '\021', '\022', '\023',
  272.                        '\235', '\205', '\010', '\207',
  273.                        '\030', '\031', '\222', '\217',
  274.                        '\034', '\035', '\036', '\037',
  275.                        '\200', '\201', '\202', '\203',
  276.                        '\204', '\012', '\027', '\033',
  277.                        '\210', '\211', '\212', '\213',
  278.                        '\214', '\005', '\006', '\007',
  279.                        '\220', '\221', '\026', '\223',
  280.                        '\224', '\225', '\226', '\004',
  281.                        '\230', '\231', '\232', '\233',
  282.                        '\024', '\025', '\236', '\032',
  283.                        '\040', '\240', '\241', '\242',
  284.                        '\243', '\244', '\245', '\246',
  285.                        '\247', '\250', '\133', '\056',
  286.                        '\074', '\050', '\053', '\041',
  287.                        '\046', '\251', '\252', '\253',
  288.                        '\254', '\255', '\256', '\257',
  289.                        '\260', '\261', '\135', '\044',
  290.                        '\052', '\051', '\073', '\136',
  291.                        '\055', '\057', '\262', '\263',
  292.                        '\264', '\265', '\266', '\267',
  293.                        '\270', '\271', '\174', '\054',
  294.                        '\045', '\137', '\076', '\077',
  295.                        '\272', '\273', '\274', '\275',
  296.                        '\276', '\277', '\300', '\301',
  297.                        '\302', '\140', '\072', '\043',
  298.                        '\100', '\047', '\075', '\042',
  299.                        '\303', '\141', '\142', '\143',
  300.                        '\144', '\145', '\146', '\147',
  301.                        '\150', '\151', '\304', '\305',
  302.                        '\306', '\307', '\310', '\311',
  303.                        '\312', '\152', '\153', '\154',
  304.                        '\155', '\156', '\157', '\160',
  305.                        '\161', '\162', '\313', '\314',
  306.                        '\315', '\316', '\317', '\320',
  307.                        '\321', '\176', '\163', '\164',
  308.                        '\165', '\166', '\167', '\170',
  309.                        '\171', '\172', '\322', '\323',
  310.                        '\324', '\325', '\326', '\327',
  311.                        '\330', '\331', '\332', '\333',
  312.                        '\334', '\335', '\336', '\337',
  313.                        '\340', '\341', '\342', '\343',
  314.                        '\344', '\345', '\346', '\347',
  315.                        '\173', '\101', '\102', '\103',
  316.                        '\104', '\105', '\106', '\107',
  317.                        '\110', '\111', '\350', '\351',
  318.                        '\352', '\353', '\354', '\355',
  319.                        '\175', '\112', '\113', '\114',
  320.                        '\115', '\116', '\117', '\120',
  321.                        '\121', '\122', '\356', '\357',
  322.                        '\360', '\361', '\362', '\363',
  323.                        '\134', '\237', '\123', '\124',
  324.                        '\125', '\126', '\127', '\130',
  325.                        '\131', '\132', '\364', '\365',
  326.                        '\366', '\367', '\370', '\371',
  327.                        '\060', '\061', '\062', '\063',
  328.                        '\064', '\065', '\066', '\067',
  329.                        '\070', '\071', '\372', '\373',
  330.                        '\374', '\375', '\376', '\377'
  331. };
  332.  
  333.  
  334. /* Mapping of ASCII codes to EBCDIC equivalents. */
  335. static char     to_ebcdic_table[256] = {
  336.                     '\000', '\001', '\002', '\003',
  337.                     '\067', '\055', '\056', '\057',
  338.                     '\026', '\005', '\045', '\013',
  339.                     '\014', '\015', '\016', '\017',
  340.                     '\020', '\021', '\022', '\023',
  341.                     '\074', '\075', '\062', '\046',
  342.                     '\030', '\031', '\077', '\047',
  343.                     '\034', '\035', '\036', '\037',
  344.                     '\100', '\117', '\177', '\173',
  345.                     '\133', '\154', '\120', '\175',
  346.                     '\115', '\135', '\134', '\116',
  347.                     '\153', '\140', '\113', '\141',
  348.                     '\360', '\361', '\362', '\363',
  349.                     '\364', '\365', '\366', '\367',
  350.                     '\370', '\371', '\172', '\136',
  351.                     '\114', '\176', '\156', '\157',
  352.                     '\174', '\301', '\302', '\303',
  353.                     '\304', '\305', '\306', '\307',
  354.                     '\310', '\311', '\321', '\322',
  355.                     '\323', '\324', '\325', '\326',
  356.                     '\327', '\330', '\331', '\342',
  357.                     '\343', '\344', '\345', '\346',
  358.                     '\347', '\350', '\351', '\112',
  359.                     '\340', '\132', '\137', '\155',
  360.                     '\171', '\201', '\202', '\203',
  361.                     '\204', '\205', '\206', '\207',
  362.                     '\210', '\211', '\221', '\222',
  363.                     '\223', '\224', '\225', '\226',
  364.                     '\227', '\230', '\231', '\242',
  365.                     '\243', '\244', '\245', '\246',
  366.                     '\247', '\250', '\251', '\300',
  367.                     '\152', '\320', '\241', '\007',
  368.                     '\040', '\041', '\042', '\043',
  369.                     '\044', '\025', '\006', '\027',
  370.                     '\050', '\051', '\052', '\053',
  371.                     '\054', '\011', '\012', '\033',
  372.                     '\060', '\061', '\032', '\063',
  373.                     '\064', '\065', '\066', '\010',
  374.                     '\070', '\071', '\072', '\073',
  375.                     '\004', '\024', '\076', '\341',
  376.                     '\101', '\102', '\103', '\104',
  377.                     '\105', '\106', '\107', '\110',
  378.                     '\111', '\121', '\122', '\123',
  379.                     '\124', '\125', '\126', '\127',
  380.                     '\130', '\131', '\142', '\143',
  381.                     '\144', '\145', '\146', '\147',
  382.                     '\150', '\151', '\160', '\161',
  383.                     '\162', '\163', '\164', '\165',
  384.                     '\166', '\167', '\170', '\200',
  385.                     '\212', '\213', '\214', '\215',
  386.                     '\216', '\217', '\220', '\232',
  387.                     '\233', '\234', '\235', '\236',
  388.                     '\237', '\240', '\252', '\253',
  389.                     '\254', '\255', '\256', '\257',
  390.                     '\260', '\261', '\262', '\263',
  391.                     '\264', '\265', '\266', '\267',
  392.                     '\270', '\271', '\272', '\273',
  393.                     '\274', '\275', '\276', '\277',
  394.                     '\312', '\313', '\314', '\315',
  395.                     '\316', '\317', '\332', '\333',
  396.                     '\334', '\335', '\336', '\337',
  397.                     '\352', '\353', '\354', '\355',
  398.                     '\356', '\357', '\372', '\373',
  399.                     '\374', '\375', '\376', '\377'
  400. };
  401.  
  402.  
  403. to_ebcdic(source, dest, count)
  404.     char           *source,
  405.                    *dest;
  406.     int             count;
  407. {
  408.     for (; count--;)
  409.     *(dest++) = to_ebcdic_table[0377 & *(source++)];
  410. }
  411.  
  412.  
  413. to_ascii(source, dest, count)
  414.     char           *source,
  415.                    *dest;
  416.     int             count;
  417. {
  418.     for (; count--;)
  419.     *(dest++) = to_ascii_table[0377 & *(source++)];
  420. }
  421. //E*O*F tables.c//
  422.  
  423. echo x - ansitape.1
  424. cat > "ansitape.1" << '//E*O*F ansitape.1//'
  425. .TH ANSITAPE 1 "23 June 1986" AICenter Merlin
  426. .\"@(#)ansitape.1 2.0 86/07/08 AICenter; by David S. Hayes
  427. .SH NAME
  428. ansitape \- ANSI-standard magtape label program
  429. .SH SYNOPSIS
  430. \fIansitape \fPtxrc\[vqfaei3\]
  431. \[\mt=\fIdevice\fP\]
  432. .RS +0.5i
  433. .br
  434. \[vo=\fIvolume-name\fP\]
  435. \[rs=\[ r | \fIrecordsize\fP \]\]
  436. \[bs=\fIblocksize\fP]
  437. .br
  438. \[rf=\[ v | f \]\]
  439. \[cc=\[ i | f | e \]\]
  440. .br
  441. \fIfilename1 filename2\fR . . .
  442. .RE -0.5i
  443. .SH DESCRIPTION
  444. .LP
  445. \fIAnsitape\fP reads, writes, and creates magtapes conforming to
  446. the ANSI standard for magtape labelling.  Primarily, this is useful
  447. to exchange tapes with VAX/VMS, which makes this kind of tape by default.
  448. .LP
  449. \fIAnsitape\fP is controlled by a function key letter
  450. .BR "(t, x, c, or r)" .
  451. Various options modify the format of the output tape.
  452. .SH "Writing ANSI Tapes"
  453. .PP
  454. The list of files on the command line is written to the tape.
  455. A full Unix pathname may be specified, however, only the last
  456. pathname component (everything after the last /) is used as
  457. the filename on the tape.
  458. .PP
  459. Normally, regular text files are to be exchanged.
  460. .I ansitape
  461. reads the files one line at a time and transfers them to the tape.
  462. The newline character at the end of each line is removed, and the
  463. file is written in a variable-length record format.  
  464. Variable-format files have the length of the longest record
  465. specified in a file header.
  466. Therefore,
  467. .I ansitape
  468. will read each input file from disk before it goes on to tape,
  469. to determine the maximum record size.  The read is skipped if
  470. the file is more than 100,000 bytes long.
  471. The default carriage control (implied)
  472. instructs the other host to restore the
  473. newline character before printing the record.
  474. .PP
  475. If \fIansitape\fP thinks that the input file is a Unix text file
  476. (Fortran or implied carriage control), it will automatically strip the
  477. the Unix newline from the end of each record.  No strip is done with
  478. embedded carriage control files, or with any file using a fixed-length
  479. record format.
  480. .PP
  481. For binary files, fixed-length records should be used.  VAX/VMS normally
  482. uses a record length of 512 bytes for things like directories and
  483. executable files, but data files may have any record length.
  484. Binary files should be flagged for embedded (\fIrf=e\fP) carriage
  485. control.
  486. .sp
  487. .SH "Reading ANSI Tapes"
  488. .PP
  489. When reading, the input file list is presumed to be the names
  490. of files to be extracted from the tape.  The shell wildcard
  491. characters asterisk (*) and question-mark (?) may be used.
  492. Of course, they must be quoted to prevent the shell from
  493. interpreting them before
  494. .I ansitape
  495. sees them.
  496. .PP
  497. None of the options for record format or carriage control need
  498. be specified when reading files.
  499. .I Ansitape
  500. will automatically pick up this information from the header
  501. records on the tape, and do the right thing.  If you can't get
  502. just what you want from
  503. .IR ansitape ,
  504. the resulting files may be run through 
  505. .IR dd(1) .
  506. .sp
  507. .SH "FUNCTION LETTERS"
  508. .PP
  509. These function letters describe the overall operation desired.
  510. One of them must be specified in the first argument to
  511. .IR ansitape .
  512. For lexically rigorous Unix fans, a minus sign (-) is allowed,
  513. but optional, to introduce the first keyword option set.
  514. .TP 6
  515. .I r
  516. Write the named files on the end of the tape.  This requires that
  517. the tape have been previously initialized with an ANSI volume header.
  518. .TP 6
  519. .I c
  520. Create a new magtape.  The tape is initialized with a new ANSI volume header.
  521. All files previously on the tape are destroyed.
  522. This option implies \fIr\fP.
  523. .TP 6
  524. .I x
  525. Extract all files from the tape.  Files are placed in the current directory.
  526. Protection is r/w to everyone, modified by the current \fIumask(2)\fP.
  527. .TP 6
  528. .I t
  529. List all of the names on the tape.
  530. .sp
  531. .SH "MODIFIER KEY LETTERS"
  532. .PP
  533. These key letters are part of the first argument to 
  534. .IR ansitape .
  535. .TP 6
  536. .I v
  537. Normally \fIansitape\fP does its work silently; the \fIv\fP (verbose) option 
  538. displays the name of each file \fIansitape\fP treats, preceded by the function
  539. letter.  It also displays the volume name of each tape as it is mounted.
  540. When used with the \fIt\fP option,
  541. \fIansitape\fP displays the number of tape blocks
  542. used by each file, the record format, and the carriage control option.
  543. .TP 6
  544. .I q
  545. Query before writing anything.  On write (c or r options), this
  546. causes \fIansitape\fP to ask before writing to the tape.  On extract
  547. operations, \fIansitape\fP displays the
  548. Unix pathname, and asks if it should extract the file.  Any response
  549. starting with a 'y' or 'Y' means yes, any other response (including
  550. an empty line) means no.
  551. .TP 6
  552. .I f
  553. File I/O is done to standard i/o instead.  For example, when writing a
  554. tape file that is to contain a lint listing, we could specify
  555. .sp
  556.     lint xyz.c | ansitape rf xyz.lint
  557. .sp
  558. instead of
  559. .sp
  560.     lint xyz.c > /tmp/xyz.lint
  561. .br
  562.     ansitape r /tmp/xyz.lint
  563. .br
  564.     rm /tmp/xyz.lint
  565. .sp
  566. When reading, this option causes the extracted files to be sent to
  567. stdout instead of a disk file.
  568. .TP 6
  569. .I a
  570. The tape should be read or written with the ASCII character set.  This
  571. is the default.
  572. .TP 6
  573. .I e
  574. The tape should be written with the EBCDIC character set.  The
  575. mapping is the same one used by the 
  576. .I dd(1)
  577. program with
  578. .IR conv=ebcdic .
  579. This option is automatically enabled if IBM-format labels are selected.
  580. .TP 6
  581. .I i
  582. Use IBM-format tape labels.  The IBM format is very similar, but
  583. not identical, to the ANSI standard.  The major difference is that
  584. the tape will contain no HDR3 or HDR4 records, thus restricting the
  585. name of the files on the tape to 17 characters.  This option automatically
  586. selects the EBCDIC character set for output.  To make an IBM-format
  587. label on a tape using the ASCII character set (why?), use the
  588. option sequence
  589. .IR ia .
  590. .TP 6
  591. .I 3
  592. Do not write HDR3 or HDR4 labels.  The HDR3 label is reserved for
  593. the use of the operating system that created the file.  HDR4 is for
  594. overflow of filenames that are longer than the 17 characters allocated
  595. in the HDR1 label.  Not all systems process these labels correctly, or
  596. even ignore them correctly.  This switch suppresses the HDR3 and HDR4
  597. labels when the tape is to be transfered to a system that would
  598. choke on them.
  599. .SH "FUNCTION MODIFIERS"
  600. .PP
  601. Each of these options should be given as a separate argument to
  602. .IR ansitape .
  603. Multiple options may be specified.  They must appear as after the
  604. key-letter options above, and before any filename arguments.
  605. .TP 6
  606. .IR mt= device
  607. Select an alternate drive on which the tape is mounted.
  608. The default is 
  609. .IR /dev/rmt8 .
  610. .TP 6
  611. .IR vo= volume-name
  612. Specify the name of the output volume.  Normally, this defaults
  613. to the first six characters of your login name.  The string 'UNIX'
  614. is used as the default if \fIansitape\fP cannot determine your login name.
  615. .TP 6
  616. .IR rs= recordsize
  617. Specify the output recordsize in bytes.  This is the maximum size
  618. in the case of variable-format files.  This option also turns on
  619. the fixed-record-format option.  Thus, if you want to have variable
  620. record sizes with a smaller maximum, you must specify
  621. .sp
  622. .ce 
  623. .IR rs= "recordsize " rf=v
  624. .sp
  625. When the recordsize is manually given, 
  626. .I ansitape
  627. does not read disk files to determine the maximum record length.
  628. .TP 6
  629. .I rs=r
  630. This is a variant of the 
  631. .I rs=
  632. option.  This causes 
  633. .I ansitape
  634. to read all disk files for recordsize, regardless of their size.
  635. Normally, files larger than 100K bytes are not scanned for recordsize.
  636. Using this option also implies variable-length records.
  637. .TP 6
  638. .IR bs= blocksize
  639. Specify the output blocksize, in bytes.  As many records as will
  640. fit are crammed into each physical tape block.  ANSI standards
  641. limit this to 2048 bytes (the default), but you may specify more
  642. or less.  Be advised that specifying more may prevent some
  643. systems from reading the tape.
  644. .TP 6
  645. .I rf=v
  646. Record format is variable-length.  In other words, they are
  647. text files.  This is the default, and should be left alone unless
  648. you really know what you're doing.
  649. .TP 6
  650. .I rf=f
  651. Record format is fixed-length.  This is usually
  652. a bad choice, and should be reserved for binary files.  This also
  653. turns off the newline strip usually done for Unix text files.
  654. .TP 6
  655. .I cc=i
  656. Carriage control implied (default).
  657. Unlike Unix text files, where records are delimited by a newline character,
  658. ANSI files do not normally include the newline as part of the record.
  659. Instead, a newline is automatically added to the record whenever it is
  660. sent to a printing device.
  661. .TP 6
  662. .I cc=f
  663. Carriage control Fortran.
  664. Each line is expected to start with a Fortran carriage-control
  665. character.  \fIAnsitape\fP does not insert these characters
  666. automatically, it merely marks the file as having them.
  667. This is of limited usefulness.  (Good opportunity for another
  668. ambitious hacker.)
  669. .TP 6
  670. .I cc=e
  671. Carriage control is embedded.  Carriage control
  672. characters (if any) are a part of the data records.  This is usually used in
  673. the case of binary data files.
  674. .TP 6
  675. .SH FILES
  676. /dev/rmt?    half-inch magnetic tape interface
  677. .br
  678. /dev/rar?    quarter-inch magnetic tape interface
  679. .br
  680. /dev/rst?    SCSI tape interface
  681. .SH "SEE ALSO"
  682. dd(1), umask(2), mtio(4), tp(5)
  683. .SH AUTHOR
  684. David S. Hayes, Site Manager, US Army Artificial Intelligence Center.
  685. Originally developed June 1986.
  686. Revised August 1986.  This software is in the public domain.
  687. .SH BUGS
  688. .LP
  689. The
  690. .I r
  691. (write) option cannot be used with quarter-inch archive tapes,
  692. since these tape drives cannot backspace.
  693. .LP
  694. There is no way to ask for the
  695. .IR n -th
  696. occurrence of a file.
  697. .LP
  698. Tape errors are handled ungracefully.
  699. .LP
  700. Files with names longer than 80 characters have the name truncated.
  701. This is a limitation of the ANSI labelling standard.  If the tape is
  702. made without HDR3 and HDR4 labels (\fI3\fP or \fIi\fP switch), the
  703. name is limited to 17 characters.
  704. .LP
  705. Multi-volume tape sets cannot yet be generated.
  706. .I ansitape
  707. will read them just fine, but it won't write them.
  708. Unix provides no device-independent way to detect
  709. a physical end-of-tape.  It was decided that a 2400-foot
  710. limitation was preferrable to device-dependence.
  711. .TP 6
  712. Note to Systems Programmers:
  713. .I ansitape
  714. uses a boolean function
  715. .I (eot)
  716. to determine when the tape drive
  717. has hit the end of file.  It is called every time a block
  718. of data is written to the tape.  If this function ever returns
  719. TRUE (a defined constant), an automatic volume switch occurs.
  720. The pertinent device registers are obtained by a MTIOCGET
  721. ioctl system call.  The registers are described in
  722. .I /sys/sundev/tmreg.h
  723. (Sun system with TapeMaster controller).  If you
  724. have a VAX, the filename will be slightly different.
  725. Sun Microsystems supplies this file even with binary-only
  726. distributions.
  727. //E*O*F ansitape.1//
  728.  
  729. echo x - ansitape.5.tbl
  730. cat > "ansitape.5.tbl" << '//E*O*F ansitape.5.tbl//'
  731. .TH ANSITAPE 5  "8 August 1986"
  732. .SH NAME
  733. ansitape - ANSI standard magtape labels
  734. .SH DESCRIPTION
  735. .PP
  736. An ANSI-labelled tape starts with a volume header.
  737. This header specifies the volume name and protection,
  738. the owner of the volume, and the ANSI label standard level
  739. that the tape conforms to.
  740. .PP
  741. Every file on the tape has a header, some data blocks, and
  742. a trailer.  A tape mark follows each of these elements.
  743. At the end of the tape, two tape marks follow the trailer,
  744. to indicate logical end-of-tape.
  745. .PP
  746. If a file is too large to be copied onto one tape, it may
  747. be continued on another tape by modifying the trailer section.
  748. .sp
  749. .SH "VOLUME HEADER"
  750. .TS
  751. expand allbox;
  752. c c c c
  753. l n c l .
  754. Field    Width    Example    Use
  755. VOL1    4    VOL1    T{
  756. Indicates this is a volume header.
  757. T}
  758. Label    6    VAX1    T{
  759. The name of the volume.
  760. T}
  761. Access    1    space    T{
  762. Volume protection.  Space means unprotected.
  763. T}
  764. IGN1    20        << ignored >>
  765. IGN2    6        << ignored >>
  766. Owner    14    Joe User    T{
  767. The name of the user.
  768. T}
  769. IGN3    28        << ignored >>
  770. Level    1    3    ANSI standard level.
  771. .TE
  772. .sp
  773. .TP 10
  774. Owner
  775. The owner field is 14 characters in ANSI labels.
  776. IBM labels cut the owner field to 10 characters.
  777. The IGN2 field is 10 characters on IBM-format tapes.
  778. .bp
  779. .SH "FILE HEADERS"
  780. .LP
  781. .TS
  782. expand allbox;
  783. c c c c
  784. l n c l .
  785. Field    Width    Example    Use
  786. HDR1    4    HDR1    T{
  787. Identifies first file header.
  788. T}
  789. Name    17    FILE.DAT    T{
  790. Leftmost 17 characters of filename.
  791. T}
  792. Set    6    VAX1    T{
  793. Name of volume set this file is part of.
  794. T}
  795. Vol Num    4    0001    T{
  796. Number of this volume within volume set.
  797. T}
  798. File Num    4    0001    T{
  799. Number of file on this tape.
  800. T}
  801. Generation    4    0001    T{
  802. Like a major release number.
  803. T}
  804. Gen Version    2    00    T{
  805. Version of a file within a release.
  806. T}
  807. Created    6    b86001    T{
  808. The date of file creation.
  809. T}
  810. Expires    6    b86365    T{
  811. Date file expires.
  812. T}
  813. Access    1    space    T{
  814. File protection.  Space means unprotected.
  815. T}
  816. Blockcount    6    000000    T{
  817. Number of blocks in the file.
  818. T}
  819. System    13    OS360    T{
  820. The name of the software system
  821. that created the tape.
  822. T}
  823. IGN    7        << ignored >>
  824. .TE
  825. .sp
  826. .TP 1i
  827. Name
  828. The filename may be up to 17 characters in IBM labels,
  829. and ANSI labels before standard level 3.
  830. On ANSI level 3 and after, the HDR4 record provides
  831. overflow storage for up to 63 more characters of filename.
  832. .TP
  833. Set Name
  834. On multi-reel tape sets, a name identifying the set as a whole.
  835. Normally, this is just the volume name of the first reel in the set.
  836. .TP
  837. Generation
  838. Like a major release number.  The version field is a version
  839. within a generation.  On VAX/VMS systems, these two fields are
  840. mathematically related to the (single) version number of disk files.
  841. .TP
  842. Created
  843. The date the file was created.  This is a six character field,
  844. where the first character is always a space.
  845. The next two are the year.  The final 3 are the day within
  846. the year, counting January 1st as day 1.
  847. .TP
  848. Blocks
  849. The number of blocks in the file.  In HDR1 records, this is
  850. always zero.  The corresponding EOF1 or EOV1 contains the
  851. number of tape blocks written in the file on the current reel.
  852. .bp
  853. .LP
  854. .TS
  855. expand allbox;
  856. c c c c
  857. l n c l .
  858. Field    Width    Example    Use
  859. HDR2    4    HDR2    T{
  860. Second file header.
  861. T}
  862. Rec Format    1    D    Record format.
  863. Blk Length    5    02048    Tape block size.
  864. Rec Length    5    00080    Record size.
  865. Density    1    3    Recording density code.
  866. Vol Switch    1    0    T{
  867. 1 if this is a continuation of a file from a previous reel.
  868. T}
  869. Job    17    user/program    See following notes.
  870. Recording    2    space    Unused in 9-track tapes.
  871. Car Control    1    space    See following notes.
  872. Blocking    1    B    See following notes.
  873. IGN    11        << ignored >>
  874. Offset    2    00    T{
  875. Bytes to skip at front of each block.
  876. T}
  877. .TE
  878. .TP
  879. Rec Format
  880. A single character indicating what type of records are
  881. provided.  The codes are
  882. .sp
  883. .TS
  884. center allbox;
  885. c c
  886. c l .
  887. Code    Meaning
  888. F    Fixed-length
  889. D    Variable up to rec length
  890. V    IBM code for variable
  891. U    Unknown
  892. .TE
  893. .TP
  894. Job
  895. The name of the job (username in Unix) right-padded
  896. to 8 characters, a slash (/), and the job step
  897. (program name in Unix) right-padded to 8 characters.
  898. This identifies where the JCL was when this file
  899. was created.
  900. .TP
  901. Carriage Control
  902. Normally a space, indicating that the records do not
  903. contain carriage control information.  When printed,
  904. each record is placed on a separate line.
  905. If an 'A' is used, the first character of each record
  906. is presumed to be a Fortran carriage-control character.
  907. VAX/VMS also uses 'M' to indicate that carriage-control
  908. is embedded as part of the data.  This is usually used
  909. in the case of binary files.
  910. .TP
  911. Blocking
  912. The B indicates that as many records as will fit are
  913. placed in a physical tape block.  Records do not cross
  914. block boundaries.  A space indicates only one record
  915. per physical tape block.
  916. .bp
  917. .LP
  918. The HDR3 and HDR4 labels are not written on IBM tapes.
  919. ANSI allows, but does not require, these labels.
  920. .sp
  921. .TS
  922. expand allbox;
  923. c c c c
  924. l n c l .
  925. Field    Width    Example    Use
  926. HDR3    4    HDR3    Third file header.
  927. OS    76        Operating-system dependent.
  928. .TE
  929. .TP
  930. OS
  931. This field is reserved for the use of the operating system
  932. that created the file.  Other operating systems are supposed
  933. to disregard HDR3 records.  On VAX/VMS, this record contains
  934. the RMS file description.
  935. .sp
  936. .LP
  937. .TS
  938. expand allbox;
  939. c c c c
  940. l n c l .
  941. Field    Width    Example    Use
  942. HDR4    4    HDR4    Fourth file header.
  943. Name 2    63        Name continuation from HDR1.
  944. Unknown    2    00    Unknown, fill with 00.
  945. IGN    11        << ignored >>
  946. .TE
  947. .TP
  948. Name 2
  949. On ANSI tapes, if the filename is longer than
  950. 17 characters, the first 17 are placed in the HDR1
  951. record.  The next 63 are put in HDR4.  Filenames
  952. longer than 80 characters are truncated.  Note
  953. that it is not required to have a HDR3 record
  954. in order to have a HDR4.
  955. .sp
  956. .SH "FILE TRAILING LABELS"
  957. .PP
  958. These labels are written after a tape file.
  959. For every label written at the head of the file,
  960. there will be a corresponding label at the tail.
  961. Except for the 
  962. .I "block count"
  963. field in HDR1, the only difference is in the name
  964. of the label.
  965. If we have reached the logical end of the file,
  966. the characters 
  967. .I HDR
  968. in the headers are replaced by the characters
  969. .I EOF
  970. in the trailing labels.
  971. If we are not at the logical end of the file, but
  972. are merely pausing at the physical end of tape before
  973. continuing on another reel, the
  974. .I HDR
  975. characters are replaced by
  976. .I EOV
  977. (end-of-volume).
  978. .PP
  979. The
  980. .I "block count"
  981. field of HDR1 was initially recorded as 000000.  When
  982. the trailers are written, the block count is changed
  983. to indicate the number of tape data blocks written.
  984. A file that is continued over several volumes maintains
  985. separate counts for each reel.
  986. .SH "RECORD FORMATS"
  987. .PP
  988. The two basic record formats are fixed and variable.
  989. .PP
  990. Fixed format uses records that are all constant length.  This
  991. is the case with VAX/VMS executable images (record length = 512).
  992. It is also used by IBM systems for text files, with a record length
  993. of 80 (card images).  The record size field of HDR2 tells how long each
  994. record is.
  995. .PP
  996. With fixed-length records, the blocksize is usually selected to
  997. be some multiple of the recordsize.  As many records as will
  998. fit are placed in each block.  Since records do not (normally)
  999. span physical tape blocks, extra space at the end of a block is wasted.
  1000. .PP
  1001. Variable-length records are used by VAX/VMS for text files.
  1002. The Unix program 
  1003. .I ansitape(1)
  1004. also turns Unix text files into variable-length tape files.
  1005. With this format, the record length specified in HDR2 is an
  1006. upper limit.
  1007. .PP
  1008. Each record is preceeded by a 4-digit (zero-filled) byte count.
  1009. The count included the digits themselves, so the minimum valid
  1010. number is 0004.  These four digits specify how long the record
  1011. is.  The data follows the digits, and is in turn followed by
  1012. the digits for the next record.
  1013. .PP
  1014. When writing, 
  1015. .I ansitape
  1016. checks to make sure that there is enough room in the tape block
  1017. for the next record.  If the record (including its length digits)
  1018. won't fit, the current block is sent to the tape, and a new
  1019. block is started.  Unused space at the end of the tape block is
  1020. filled with circumflex (^) characters.
  1021. //E*O*F ansitape.5.tbl//
  1022.  
  1023. echo Possible errors detected by \'wc\' [hopefully none]:
  1024. temp=/tmp/shar$$
  1025. trap "rm -f $temp; exit" 0 1 2 3 15
  1026. cat > $temp <<\!!!
  1027.       83     363    2185 Makefile
  1028.      149     881    5555 ansitape.h
  1029.      156     578    5687 tables.c
  1030.      302    1797   10559 ansitape.1
  1031.      290    1477    7890 ansitape.5.tbl
  1032.      980    5096   31876 total
  1033. !!!
  1034. wc  Makefile ansitape.h tables.c ansitape.1 ansitape.5.tbl | sed 's=[^ ]*/==' | diff -b $temp -
  1035. exit 0
  1036. -- 
  1037.     David S. Hayes, The Merlin of Avalon
  1038.     PhoneNet:    (202) 694-6900
  1039.     ARPA:        merlin%hqda-ai.uucp@brl-smoke
  1040.     UUCP:        ...!seismo!sundc!hqda-ai!merlin
  1041.  
  1042.